import Sequelize from 'sequelize'
import sequelize from './../../../database'

export const InternalType = sequelize.define('internal_type',{
    id:{
        type: Sequelize.UUIDV4,
        defaultValue: Sequelize.UUIDV4,
        unique: true,
        allowNull: false,
        primaryKey:true
    },
    internal_type_name :{
        type: Sequelize.STRING,
        allowNull: false
    },
    status: {
        type: Sequelize.INTEGER,
        defaultValue: 0,
        allowNull: false
    },
    memo: {
        type: Sequelize.STRING,
        allowNull: false
    },
    created_man: {
        type: Sequelize.STRING,
        allowNull: false
    }
},{
    freezeTableName:false,
    tableName: 'internal_type',
    updatedAt:'updated_at',
    createdAt:'created_at'
});

class InternalTypeModel{
    insert(record){
        return InternalType.create(record);
    }
    update(record){
        return InternalType.update(
            {
                'where':{
                    'id': record.id
                }
            }
        )
    }
    delete(id){
        return InternalType.destroy({id: id});
    }
    findById(id){
        return InternalType.findById(id);
    }
    findAll(){
        return InternalType.findAll();
    }
}
module.exports = new InternalTypeModel();